package com.blb.day2;

public class VolatileTest {

    //用于控制线程的执行
    static volatile boolean run = true;

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            System.out.println("start");
            while(run){}
            System.out.println("end");
        }).start();
        Thread.sleep(2000);
        //修改变量的值
        run = false;
    }
}
